#include "Arduino.h"
#include "Step.h"

// ################# CONSTRUCTORS ####################
Step::Step(boolean trig){
	_trigOn = false;
	_gateOn = false;
	
	_trig = trig;
	
	if(_trig){
		_value = 1023;
		_prevValue = 0;
	}else {
		_value = 0;
		_prevValue = 1023;
	}
}

Step::Step(int value){
	_trigOn = false;
	_gateOn = false;

	 if(_value <= 0){
		_value = 0;
		_prevValue = 1023;
		_trig = false;
	 }else if(_value > 1023){
		_value = 1023;
		_prevValue = 0;
		_trig = true;
	}else{
		_value = 1023;
		_prevValue = 0;
		_trig = true;
	}
}

// ################### METHODS ###############################

// Accessors
int Step::getValue(){
	return _value;
}
	
boolean Step::getTrig(){
	return _trig;
}
	
boolean Step::getGate(){
	return _gate;
}


// Modifiers
void Step::setValue(int value){
	if(_value <= 0){
		_value = 0;
		_trig = false;
	}else if(_value > 1023){
		_value = 1023;
		_trig = true;
	}else{
		_value = 1023;
		_trig = true;
	}
}
	
void Step::setTrig(boolean trig){
	_trig = trig;
}

void Step::setGate(boolean gate){
	_gate = gate;
}

void Step::toggleTrig(){
	_trig = !_trig;
}
	
void Step::toggleGate(){
	_gate = !_gate;
}